let app = getApp();

var applet_park_api_url = app.globalData.applet_park_api_url;
const {
  requestDataparams
} = require('../../../utils/request.js');
Page({

  /**
   * 页面的初始数据
   */
  data: {
    lists:[],
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var that = this;
    that.getDatas();
  },
  getDatas(){
    var that = this;
    var openId = app.globalData.openId || wx.getStorageInfoSync('OPENID');
    requestDataparams('/api/unifiedOrder/queryMyRent',{openId:openId},'POST', 'json').then(response=>{
      
      if(response.data.code==0) {
        var datas = response.data.data;
        
        for(var i =0; i<datas.length; i++){
           datas[i]['overtime'] = true;
           datas[i].endTime = datas[i].endTime.substring(0,10);
           if(!that.checkDate(datas[i].endTime)){//过期
             datas[i]['overtime'] = false;
           }
        }
        that.setData({
          lists: datas
        })
        
      }
    })
  },
  checkDate(date){
    var normalizeDate = date.split("-");
    var Month = new Date().getMonth() + 1;
    var year = new Date().getFullYear();

    if (normalizeDate[0] < year) {

        return false
    } else if(normalizeDate[0] == year){
        if (normalizeDate[1] < Month) {
            
            return false;
        }else if(normalizeDate[1] == Month){
            if (normalizeDate[2] < this.day) {
                return false;
            }else {
                return true;
            };
        }else {
            return true;
        };
    } else{
        return true;
    };

},
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})